package cn.yudao.ymcc.mq.consumer;


import cn.yudao.ymcc.dto.AliPayNotifyMqDto;
import cn.yudao.ymcc.service.ICourseOrderService;
import com.alibaba.fastjson.JSONObject;
import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.nio.charset.StandardCharsets;

@Component
@RocketMQMessageListener(consumerGroup="service-order-level-consumer",
        topic="topic-order-level",
        selectorExpression="tags-order-level",
        messageModel = MessageModel.BROADCASTING) // 广播模式
public class OrderLevelConsumer implements RocketMQListener<MessageExt> {

    @Autowired
    private ICourseOrderService courseOrderService;



    @Override
    public void onMessage(MessageExt message) {

        byte[] body = message.getBody();
        String orderNo = new String(body, StandardCharsets.UTF_8);
        // 调用方法执行业务 -- 不报错会自动完成签名
        courseOrderService.OrderLevel(orderNo);
    }
}
